package org.demo.ioc.pc;

import org.demo.ioc.facade.Motherboard;

public class Computer {
	private Motherboard motherboard;

	public void setMotherboard(Motherboard motherboard) {
		this.motherboard = motherboard;
	}

	public void doWork() {
		System.out.println("Start booting....");
		for (int i = 0; i < 100; i++)
			System.out.print(i + " ");
		System.out.println("");
		System.out.println("Job done!");
	}

	public void start() {
		motherboard.poweron();
	}

	public void shutdown() {
		motherboard.shutdown();
	}

	public double getPrice() {
		return motherboard.getPrice() + motherboard.getCpu().getPrice()
				+ motherboard.getRam().getPrice();
	}

	public String getSetting() {
		String ret;
		ret = "Couputer configuration: \n Motherboard:" + motherboard.getName()
				+ " \n CPU: " + motherboard.getCpu().getName() + " \n RAM:"
				+ motherboard.getRam().getName() + "\n";
		ret += "Price is " + getPrice();
		return ret;
	}
}
